<#import "../macro/components.ftl" as components/>
<#include "../macro/layout_default.ftl"/>

<@head>
<link rel="stylesheet" href="/misc/app/css/product_list.css"/>
</@head>

<@body>
<script src="/misc/app/js/lgsBills_new.js"></script>
<script src="/misc/jquery-fileupload-9.14.0/jquery.ui.widget.js"></script>
<script src="/misc/jquery-fileupload-9.14.0/jquery.fileupload.js"></script>
<script src="/misc/adminlte-2.3.7/plugins/twitter-bootstrap-v2/docs/assets/js/bootstrap-typeahead.js"></script>
<script>var PicDomain = "${PicDomain!}"</script>
<script>
    jQuery('#search_cust_to').typeahead({
        source: function (query, process) {
            var parameter = {'name_code': query};
            $.get('/getCustSearchList', parameter, function (data) {
                var resultstr = "";
                for(i=0;i<data.length;i++)
                {
                    resultstr +=","+data[i].custName+"_"+data[i].custCode+"_"+data[i].id;
                }
                resultstr = resultstr.substring(1);
                var result = resultstr.split(",");
                process(result);
            });
        },
        updater: function (item) {
            $("#toId").val(item.split("_")[2]);
            //console.log($("#pid").val());
            item=item.split("_")[0]+"_"+item.split("_")[1];
            return item.replace(/<a(.+?)<\/a>/, ""); //这里一定要return，否则选中不显示
        },
        items: 10, //显示8条
        delay: 500 ,//延迟时间
        minLength: 1

    });

    jQuery('#search_cust_from').typeahead({
        source: function (query, process) {
            var parameter = {'name_code': query};
            $.get('/getCustSearchList', parameter, function (data) {
                var resultstr = "";
                for(i=0;i<data.length;i++)
                {
                    resultstr +=","+data[i].custName+"_"+data[i].custCode+"_"+data[i].id;
                }
                resultstr = resultstr.substring(1);
                var result = resultstr.split(",");
                process(result);
            });
        },
        updater: function (item) {
            $("#fromId").val(item.split("_")[2]);
            //console.log($("#pid").val());
            item=item.split("_")[0]+"_"+item.split("_")[1];
            return item.replace(/<a(.+?)<\/a>/, ""); //这里一定要return，否则选中不显示
        },
        items: 10, //显示8条
        delay: 500 ,//延迟时间
        minLength: 1

    });
</script>

</@body>

<@layout_default>

<!--===========点击“创建单据”按钮，显示新建单据页面  start================--->
<div class="box" name="md_add_Bills">
  <div class="box-header">
    <!--<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
    </button>-->
    <h4 class="modal-title"><i class="fa fa-plus"></i> 创建单据</h4>
  </div>
  <div class="box-body">
    <form class="form-horizontal" name="form_new_bill">
      <div class="form-group">
        <label class="col-sm-2 control-label" name="namelabel"><strong class="text-red bold">*</strong> 单号</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" style="width:550px;display: inline" placeholder="单据号" name="billsNo" id="billsNo" maxlength="25" />
            <button type="button" class="btn btn-default" id="auto-billsNo">自动生成</button>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 选择产品</label>
        <div class="col-sm-10">
          <button type="button" class="btn btn-default" name="btn_select_product" data-toggle="modal"
                  data-target="#selectedProduct_modals"><i class="fa fa-plus"></i> 选择产品
          </button>
            <input type="hidden" value="${isBridgeCompany}" id="isBridgeCompany">
        </div>
      </div>

      <div class="form-group" id="selectedProDiv">
        <label class="col-sm-2 control-label"></label>
        <div class="col-sm-10">
          <table class="table table-striped table-hover">
            <thead>
            <tr>
              <th>ID</th>
              <th>产品名称</th>
              <th>产品编号</th>
              <th>条形码</th>
              <th>规格</th>
              <th>数量(箱)</th>
              <th>数量(瓶)</th>
              <th>操作</th>
            </tr>
            </thead>
            <tbody id="product_table">
              
            </tbody>
          </table>
        </div>
      </div>
      
        <div class="form-group">
	        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 操作类型</label>
	        <div class="col-sm-10">
	            <select class="form-control" name="nodeId" id="nodeSelect">
	                <option value="">请选择操作类型</option>
                    <#if (nodeList?size > 0)>
                      <#list nodeList as item>
                          <option value="${item.id}" data-node-type="${item.type}">${item.name}</option>
                      </#list>
                    </#if>
	            </select>
	        </div>
        </div>
        <div class="form-group hide" id="toDepot">
            <input type="hidden"  id="toId" name ="toId"/>
	        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 收货对象</label>
	        <div class="col-sm-10">
                <input type="text" class="form-control" placeholder="收货对象" name="name_code"
                       id="search_cust_to" data-provide="typeahead" data-items="10" autocomplete="off" />
	        </div>
	    </div>
        <div class="form-group hide" id="fromDepot">
            <input type="hidden"  id="fromId" name ="fromId"/>
	        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 发货对象</label>
	        <div class="col-sm-10">
                <input type="text" class="form-control" placeholder="发货对象" name="name_code"
                       id="search_cust_from" data-provide="typeahead" data-items="10" autocomplete="off" />
	        </div>
	    </div>
      
      <div class="form-group" id="win_div">
        <label class="col-sm-2 control-label">单据凭证</label>
        <div class="col-sm-10">
          <p class="help-block"><i class="fa fa-info-circle text-yellow"></i>点击预览图可删除图片，图片数量限制3张，图片尺寸：640*1030</p>
          <span class="ctn-product-pics" id="ctn_new_product_pics_win"></span>
          <input type="file" id="ipt_new_product_upload_pic_win" class="hide" name="file"/>
          <button type="button" class="btn-upload-productimg" name="btn_new_product_upload_pic_win"><i
              class="fa fa-plus"></i></button>
          
        </div>
      </div>
      
      <div class="form-group">
        <label class="col-sm-2 control-label">备注</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" placeholder="备注" name="summary" maxlength="100" />
        </div>
      </div>
      
    </form>

  </div>
  <div class="box-footer text-center">
    <button type="button" class="btn btn-default" name="btn_cancel_new_bill">取消</button>
    <button type="button" class="btn btn-primary" name="btn_save_new_bill">保存</button>
  </div>
</div>
<!--===========点击“创建单据”按钮，显示新建单据页面  end================--->


<!--===========Modals  点击“选择商品”按钮，显示商品列表   start================--->
<div class="modal" id="selectedProduct_modals" tabindex="-1">
  <div class="modal-dialog" role="document" style="width:700px;">
    <div class="modal-content">
      <div class="modal-header">
      	<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
        <h5 class="modal-title"><i class="fa fa-plus"></i> 选择商品</h5>
      </div>
      <span class="pull-right text-muted" style="margin: 14px 10px 0 0;">共<span id="proTotal">${productList.resultTotal}</span> 条记录</span>
      <form class="form-inline" action="">
        <div class="input-group">
          <div class="input-group-addon">关键字</div>
          <input type="text" class="form-control" style="width: 260px" name="keyword" value="${keyword!}"
                 placeholder="名称、编号、品牌"/>
        </div>

        <button type="button" class="btn btn-warning" name="pro_query"><i class="fa fa-search"></i> 查询</button>
      </form>
      <div class="modal-body">
        <table class="table table-striped table-hover">
          <thead>
          <tr>
            <th></th>
            <th>ID</th>
            <th>产品名称</th>
            <th>产品编号</th>
            <th>条形码</th>
            <th>规格</th>
            <th>数量(箱)</th>
            <th>数量(瓶)</th>
          </tr>
          </thead>
          <tbody id="product_model">
            <#list productList.result as item>
            <tr>
              <td>
                <input type="checkbox" name="product" value="${item.id!}" id="product_${item.id!}"/>
              </td>
              <td>${item.id}</td>
              <td class="name_${item.id!}">${item.name}</td>
              <td class="number_${item.id!}">${item.number}</td>
              <td class="bar_${item.id!}">${item.barcode}</td>
              <td class="pbc_${item.id!}">1 * ${item.pbcPcount!}</td>
              <td>
                 <input type="text" class="nubs" id="nubs_${item.id!}"  data-id="${item.id!}" data-pbcpcount="${item.pbcPcount!}" size="5"/>
              </td>
              <td id="botnum_${item.id!}" class="botnum">
              </td>
            </tr>
            </#list>
          </tbody>
        </table>
      </div>
      <div class="box-footer text-center" id="page_model" data-total="${productList.pageTotal}"
           data-size="${productList.pageSize}">
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal" id="selectPro_cancel">取消</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal" id="selectPro_confirm">确认</button>
      </div>
    </div>
  </div>
</div>
<!--===========点击“选择商品”按钮，显示商品列表   end================--->




</@layout_default>